using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Dynamic;
using System.Linq;
using System.Reflection;

public class DynamicModel : DynamicObject, INotifyPropertyChanged
{
    private readonly Dictionary<string, object> _properties = new();

    public event PropertyChangedEventHandler PropertyChanged;

    public void SetProperty(string name, object value)
    {
        _properties[name] = value;
        PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
    }

    public object GetProperty(string name)
    {
        return _properties.TryGetValue(name, out var value) ? value : null;
    }

    public override bool TryGetMember(GetMemberBinder binder, out object result)
    {
        result = GetProperty(binder.Name);
        return true;
    }

    public override bool TrySetMember(SetMemberBinder binder, object value)
    {
        SetProperty(binder.Name, value);
        return true;
    }
}
